<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!doctype html>
<html class="no-js" lang="zxx">

<head>
    <meta charset="utf-8">
    <meta content="ie=edge" http-equiv="x-ua-compatible">
    <title>Beck - Furniture eCommerce Bootstrap 5 Template</title>
    <meta content="" name="description">
    <meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name="viewport">
    <!-- Favicons -->


    <!-- ************************* CSS Files ************************* -->

    <!-- Bootstrap CSS -->
    <link href="<%=request.getContextPath() %>/senshi_official_website/static/css/bootstrap.css" rel="stylesheet">

    <!-- Vendor CSS -->
    <link href="<%=request.getContextPath() %>/senshi_official_website/static/css/vendor.css" rel="stylesheet">

    <!-- style css -->
    <link href="<%=request.getContextPath() %>/senshi_official_website/static/css/main.css" rel="stylesheet">
</head>

<body>

<!-- Preloader Start -->
<div class="ft-preloader active">
    <div class="ft-preloader-inner h-100 d-flex align-items-center justify-content-center">
        <div class="ft-child ft-bounce1"></div>
        <div class="ft-child ft-bounce2"></div>
        <div class="ft-child ft-bounce3"></div>
    </div>
</div>
<!-- Preloader End -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="exampleModalLabel">请选择尺码</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div id ="product">

            </div>
            <div class="modal-body">
                <div class="form-check">
                    <input class="form-check-input" type="radio" name="size" id="sizeS" value="1" checked>
                    <label class="form-check-label" for="sizeS">
                        S
                    </label>
                </div>
                <div class="form-check">
                    <input class="form-check-input" type="radio" name="size" id="sizeM" value="2">
                    <label class="form-check-label" for="sizeM">
                        L
                    </label>
                </div>
                <div class="form-check">
                    <input class="form-check-input" type="radio" name="size" id="sizeL" value="3" >
                    <label class="form-check-label" for="sizeL">
                        XL
                    </label>
                </div>
                <div class="form-check">
                    <input class="form-check-input" type="radio" name="size" id="sizeXL" value="4" >
                    <label class="form-check-label" for="sizeXL">
                        XXL
                    </label>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" onclick="updateSize()"  class="btn btn-size-md btn-shape-square btn-fullwidth" data-dismiss="modal">确定</button>
            </div>
        </div>
    </div>
</div>
<!-- Main Wrapper Start -->
<div class="wrapper">
    <!-- Header Start -->
    <header class="header">
        <div class="header__inner fixed-header">
            <div class="header__main">
                <div class="container-fluid">
                    <div class="row">
                        <div class="col-12">
                            <div class="header__main-inner">
                                <div class="header__main-left">
                                    <div class="logo">
                                        <a href="<%=request.getContextPath() %>/index.jsp" class="logo--normal">
                                            <img src="<%=request.getContextPath() %>/senshi_official_website/static/logo1.png"
                                                 width="70%"
                                                 height="70%"
                                                 alt="Logo">
                                        </a>
                                    </div>
                                </div>
                                <div class="header__main-center">
                                    <nav class="main-navigation text-center d-none d-lg-block">
                                        <ul class="mainmenu">
                                            <li class="mainmenu__item menu-item-has-children">
                                                <a href="<%=request.getContextPath() %>/index.jsp"
                                                   class="mainmenu__link">
                                                    <span class="mm-text">首页</span>
                                                </a>
                                            </li>
                                            <li class="mainmenu__item menu-item-has-children megamenu-holder">
                                                <a href="<%=request.getContextPath() %>/shop-three-columns.jsp"
                                                   class="mainmenu__link">
                                                    <span class="mm-text">购物</span>
                                                </a>
                                            </li>
                                            <li class="mainmenu__item menu-item-has-children">
                                                <a href="#" class="mainmenu__link">
                                                    <span class="mm-text">个人中心</span>
                                                </a>
                                                <ul class="sub-menu">
                                                    <li>
                                                        <a href="<%=request.getContextPath() %>/goMyAccount">
                                                            <span class="mm-text">我的账号</span>
                                                        </a>
                                                    </li>
                                                    <li>
                                                        <a href="goCart">
                                                            <span class="mm-text">购物车</span>
                                                        </a>
                                                    </li>
                                                    <li>
                                                        <a href="<%=request.getContextPath() %>/goTracking">
                                                            <span class="mm-text">跟踪订单</span>
                                                        </a>
                                                    </li>
                                                </ul>
                                            </li>
                                            <li class="mainmenu__item">
                                                <a href="<%=request.getContextPath() %>/contact-us.jsp"
                                                   class="mainmenu__link">
                                                    <span class="mm-text">联系我们</span>
                                                </a>
                                            </li>
                                        </ul>
                                    </nav>
                                </div>
                                <div class="header__main-right">
                                    <div class="header-toolbar-wrap">
                                        <div class="header-toolbar">
                                            <div class="header-toolbar__item header-toolbar--search-btn">
                                                <a href="#searchForm" class="header-toolbar__btn toolbar-btn">
                                                    <i class="la la-search"></i>
                                                </a>
                                            </div>
                                            <div class="header-toolbar__item header-toolbar--minicart-btn">
                                                <a href="#miniCart" class="header-toolbar__btn toolbar-btn">
                                                    <i class="la la-shopping-cart"></i>
                                                    <span>01</span>
                                                </a>
                                            </div>
                                            <div class="header-toolbar__item d-block d-lg-none">
                                                <a href="#offcanvasMenu"
                                                   class="header-toolbar__btn toolbar-btn menu-btn">
                                                    <div class="hamburger-icon">
                                                        <span></span>
                                                        <span></span>
                                                        <span></span>
                                                        <span></span>
                                                        <span></span>
                                                        <span></span>
                                                    </div>
                                                </a>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </header>
    <!-- Header End -->

    <!-- Breadcrumb area Start -->
    <section class="page-title-area bg-image ptb--80" data-bg-image="assets/img/bg/page_title_bg.jpg">
        <div class="container">
            <div class="row">
                <div class="col-12 text-center">
                    <h1 class="page-title">购物车</h1>
                    <ul class="breadcrumb">
                        <li><a href="<%=request.getContextPath() %>/index.jsp">首页</a></li>
                        <li class="current"><span>购物车</span></li>
                    </ul>
                </div>
            </div>
        </div>
    </section>
    <!-- Breadcrumb area End -->

    <!-- Main Content Wrapper Start -->
    <div class="main-content-wrapper">
        <div class="page-content-inner ptb--80 pt-md--40 pb-md--60">
            <div class="container">
                <div class="row">
                    <div class="col-lg-8 mb-md--50">
                        <form action="#" class="cart-form">
                            <div class="row g-0">
                                <div class="col-12">
                                    <div class="table-content table-responsive">
                                        <table class="table text-center">
                                            <thead>
                                            <tr>
                                                <th>&nbsp;</th>
                                                <th class="text-start">产品</th>
                                                <th>尺码</th>
                                                <th>单价</th>
                                                <th>数量</th>
                                                <th>总价</th>
                                            </tr>
                                            </thead>
                                            <tbody id="shop_cart">
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                            <div class="row g-0 border-top pt--20 mt--20">
                                <div class="col-sm-6">
                                    <div class="coupon">
                                        <input class="cart-form__input" id="coupon" name="coupon"
                                               placeholder="Coupon Code"
                                               type="text">
                                        <button class="cart-form__btn" type="submit">使用优惠卷</button>
                                    </div>
                                </div>
                                <div class="col-sm-6 text-sm-end">
                                    <button class="cart-form__btn"
                                            onclick="emptyShopCart(17766040934)<%--emptyShopCart(${sessionScope.Consumer.phone})--%>"
                                            type="submit">清空所有购物车
                                    </button>
                                    <button class="cart-form__btn"
                                            onclick="getCart(17766040934)<%--getCart(${sessionScope.Consumer.phone})--%>"
                                            type="submit">刷新我的购物车
                                    </button>
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="col-lg-4">
                        <div class="cart-collaterals">
                            <div class="cart-totals">
                                <h5 class="font-size-14 font-bold mb--15">购物总价</h5>
                                <div class="cart-calculator">
                                    <div class="cart-calculator__item">
                                        <div class="cart-calculator__item--head">
                                            <span>小计</span>
                                        </div>
                                        <div class="cart-calculator__item--value">
                                            <span id="subtotal"></span>
                                        </div>
                                    </div>
                                    <div class="cart-calculator__item">
                                        <div class="cart-calculator__item--head">
                                            <span>运费</span>
                                        </div>
                                        <div class="cart-calculator__item--value">
                                            <span>到付</span>

                                        </div>
                                    </div>
                                    <div class="cart-calculator__item order-total">
                                        <div class="cart-calculator__item--head">
                                            <span>总价</span>
                                        </div>
                                        <div class="cart-calculator__item--value">
                                                <span class="product-price-wrapper">
                                                    <span class="money" id="TotalPrice"></span>
                                                </span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <a class="btn btn-size-md btn-shape-square btn-fullwidth" onclick="goCheckout()">
                                付 款
                            </a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- Main Content Wrapper Start -->

    <!-- Footer Start-->
    <footer class="footer bg-color" data-bg-color="#f4f8fa">
        <div class="footer-top">
            <div class="container-fluid">
                <div class="row border-bottom pt--70 pb--70">
                    <div class="col-lg-3 col-sm-6 offset-md-1 offset-lg-0 mb-md--45">
                        <div class="footer-widget">
                            <div class="textwidget">
                                <figure class="footer-logo mb--30">
                                    <img src="senshi_official_website/static/logo1.png" width="50%" height="50%"
                                         alt="Logo">
                                </figure>
                                <p>
                                    追求品质生活，打造更舒服的家居生活就选择森饰家具，给自己一份放心，更是给自己的一份安心</p>
                            </div>
                        </div>
                    </div>
                    <div class="col-lg-2 col-sm-3 offset-lg-1 offset-sm-2 mb-md--45">
                        <div class="footer-widget">
                            <h3 class="widget-title mb--35 mb-sm--20">公司简介</h3>
                            <div class="footer-widget">
                                <ul class="footer-menu">
                                    <li><a href="">关于我们</a></li>
                                    <li><a href="#">事务</a></li>
                                    <li><a href="contact-us.html">联系我们</a></li>
                                </ul>
                            </div>
                        </div>
                    </div>
                    <div class="col-lg-2 col-sm-4 offset-md-1 offset-lg-0 mb-xs--45">
                        <div class="footer-widget">
                            <h3 class="widget-title mb--35 mb-sm--20">产品</h3>
                            <div class="footer-widget">
                                <ul class="footer-menu">
                                    <li><a href="#">价格</a></li>
                                    <li><a href="#">产品特征</a></li>
                                    <li><a href="#">客户</a></li>
                                    <li><a href="#">演示</a></li>
                                </ul>
                            </div>
                        </div>
                    </div>
                    <div class="col-lg-2 col-sm-4 mb-xs--45">
                        <div class="footer-widget">
                            <h3 class="widget-title mb--35 mb-sm--20">帮助</h3>
                            <div class="footer-widget">
                                <ul class="footer-menu">
                                    <li><a href="#">介绍</a></li>
                                    <li><a href="#">反馈</a></li>
                                    <li><a href="#">首页</a></li>
                                </ul>
                            </div>
                        </div>
                    </div>
                    <div class="col-lg-2 col-md-3 col-sm-4">
                        <div class="footer-widget">
                            <h3 class="widget-title mb--35 mb-sm--20">社交</h3>
                            <div class="footer-widget">
                                <ul class="footer-menu">
                                    <li><a href="#">脸书</a></li>
                                    <li><a href="#">推特</a></li>
                                    <li><a href="#">领英</a></li>
                                    <li><a href="#">Google +</a></li>
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="footer-middle ptb--40">
            <div class="container">
                <div class="row justify-content-center">
                    <div class="col-lg-11">
                        <div class="footer-widget">
                            <div class="taglist">
                                <a href="#">隐私政策</a>
                                <a href="#">缺陷披露政策</a>
                                <a href="#">使用条款</a>
                                <a href="#">上海工商</a>
                                <a href="#">沪公网安备31010402001234号</a>
                                <a href="#">沪ICP备170555232号</a>
                                <a href="#">Cookies设置</a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </footer>
    <!-- Footer End-->

    <!-- OffCanvas Menu Start -->
    <div class="offcanvas-menu-wrapper" id="offcanvasMenu">
        <div class="offcanvas-menu-inner">
            <a class="btn-close" href="">
                <i class="la la-remove"></i>
            </a>
            <nav class="offcanvas-navigation">
                <ul class="offcanvas-menu">
                    <li class="menu-item-has-children active">
                        <a href="../index.jsp">首页</a>
                    </li>
                    <li class="menu-item-has-children">
                        <a href="../shop-three-columns.jsp">购物</a>
                    </li>
                    <li class="menu-item-has-children">
                        <a href="#">个人中心</a>
                        <ul class="sub-menu">
                            <li>
                                <a href="/goMyAccount">我的账号</a>
                            </li>
                            <li>
                                <a href="/goCart">购物车</a>
                            </li>

                            <li>
                                <a href="/goTracking">跟踪订单</a>
                            </li>

                        </ul>
                    </li>
                    <li>
                        <a href="../contact-us.jsp">联系我们</a>
                    </li>
                </ul>
                <div class="site-info vertical">
                    <div class="site-info__item">
                        <a href="tel:+01223566678"><strong>+01 2235 666 78</strong></a>
                        <a href="mailto:Support@contixs.com">Support@furtrate.com</a>
                    </div>
                </div>
            </nav>
        </div>
    </div>
    <!-- OffCanvas Menu End -->

    <!-- Mini Cart Start -->
    <aside class="mini-cart" id="miniCart">
        <div class="mini-cart-wrapper">
            <div class="mini-cart__close">
                <a class="btn-close" href="#"><i class="la la-remove"></i></a>
            </div>
            <div class="mini-cart-inner">
                <h3 class="mini-cart__heading mb--45">Shopping Cart</h3>
                <div class="mini-cart__content">
                    <ul class="mini-cart__list">
                        <li class="mini-cart__product">
                            <a class="mini-cart__product-remove" href="#">
                                <i class="la la-remove"></i>
                            </a>
                            <div class="mini-cart__product-image">
                                <img alt="products"
                                     src="<%=request.getContextPath() %>/senshi_official_website/static/picture/prod-01-100x100.jpg">
                            </div>
                            <div class="mini-cart__product-content">
                                <a class="mini-cart__product-title"
                                   href="<%=request.getContextPath() %>/senshi_official_website/product-details.html">Golden
                                    Easy Spot
                                    Chair.</a>
                                <span class="mini-cart__product-quantity">1 x $49.00</span>
                            </div>
                        </li>
                        <li class="mini-cart__product">
                            <a class="mini-cart__product-remove" href="#">
                                <i class="la la-remove"></i>
                            </a>
                            <div class="mini-cart__product-image">
                                <img alt="products"
                                     src="<%=request.getContextPath() %>/senshi_official_website/static/picture/prod-02-100x100.jpg">
                            </div>
                            <div class="mini-cart__product-content">
                                <a class="mini-cart__product-title"
                                   href="<%=request.getContextPath() %>/senshi_official_website/product-details.html">Golden
                                    Easy Spot
                                    Chair.</a>
                                <span class="mini-cart__product-quantity">1 x $49.00</span>
                            </div>
                        </li>
                        <li class="mini-cart__product">
                            <a class="mini-cart__product-remove" href="#">
                                <i class="la la-remove"></i>
                            </a>
                            <div class="mini-cart__product-image">
                                <img alt="products"
                                     src="<%=request.getContextPath() %>/senshi_official_website/static/picture/prod-03-100x100.jpg">
                            </div>
                            <div class="mini-cart__product-content">
                                <a class="mini-cart__product-title"
                                   href="<%=request.getContextPath() %>/senshi_official_website/product-details.html">Golden
                                    Easy Spot
                                    Chair.</a>
                                <span class="mini-cart__product-quantity">1 x $49.00</span>
                            </div>
                        </li>
                    </ul>
                    <div class="mini-cart__total">
                        <span>Subtotal</span>
                        <span class="ammount">$98.00</span>
                    </div>
                    <div class="mini-cart__buttons">
                        <a class="btn btn-fullwidth btn-bg-primary mb--20" href="">查看购物车</a>
                        <a class="btn btn-fullwidth btn-bg-primary" onclick="goCheckout()" >结账</a>
                    </div>
                </div>
            </div>
        </div>
    </aside>
    <!-- Mini Cart End -->

    <!-- 搜索框 -->
    <div class="searchform__popup" id="searchForm">
        <a class="btn-close" href="#"><i class="la la-remove"></i></a>
        <div class="searchform__body">
            <p>Start typing and press Enter to search</p>
            <form class="searchform">
                <input class="searchform__input" id="popup-search" name="popup-search"
                       placeholder="Search Entire Store..."
                       type="text">
                <button class="searchform__submit" type="submit"><i class="la la-search"></i></button>
            </form>
        </div>
    </div>
</div>
<!-- Main Wrapper End -->
<!-- ************************* JS Files ************************* -->
<!-- jQuery JS -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.3/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<script src="<%=request.getContextPath() %>/senshi_official_website/static/js/vendor.js"></script>
<script src="<%=request.getContextPath() %>/senshi_official_website/static/js/main.js"></script>
<script src="<%=request.getContextPath() %>/senshi_official_website/static/js/jquery.js"></script>

<!-- Main JS -->




</body>
<script>
    $(function () {
        init()
    })

    function init() {
        let name = "${sessionScope.consumer.consumerName}";

        if (name !== "" && name != null) {
            console.log(name)
            $("#userName").html("欢迎" + name);


        } else {
            $("#userName").html = "登录 & 注册";
        }
    }

    $(function () {
        const phone =${sessionScope.consumer.consumerPhone};

        getCart(phone);
        priceBill(phone)


    })

    function getCart(phoneNumber) {
        $.ajax({
            url: "shopCart/" + phoneNumber,
            dataType: "json",
            type: "GET",
            contentType: "application/json; charset=UTF-8",
            success: function (data) {
                let shopCart = data.data;
                $("#shop_cart").empty();
                shopCart.forEach((product, index) => {
                    const row = $("<tr></tr>");
                    let productPrice = product.productQuantity * product.price;
                    let price_id = "productPrice-" + index;
                    const removeCell = $(`<td class='product-remove text-start' ><a ><i class='la la-remove' onclick='removeFromShopCart(\${product.id})'></i></a></td>`);
                    const thumbnailCell = $(`<td class='product-thumbnail text-start'>
<img alt='Product Thumnail' src='senshi_official_website/static/picture/\${product.productImage}' width="70%" height="88%"><h6>
<strong style="padding-left: 13% ">\${product.productName}</strong></h6></td>`);
                    const sizeName = $(`<td onclick="showSize('\${product.productImage}',\${product.id},'\${product.productName}','\${product.sizeName}')" data-toggle="modal" data-target="#myModal"  >
<span class='product-price-wrapper'><span class='money'>\${product.sizeName}</span></span></td>`);
                    const priceCell = $(`<td class='product-price'><span class='product-price-wrapper'><span class='money'>￥\${product.price}</span></span></td>`);
                    const quantityCell = $(`<td class='product-quantity'>
<div >
<input   onkeydown="key_8(this)"  onblur="count_price(\${product.price},this,\${index},\${product.id})" class=' quantity-input'  min='1'  type='number' value='\${product.productQuantity}'>
</div>
</td>`);
                    const totalCell = $(`<td class='product-total-price'><span class='product-price-wrapper'><input style="text-align: center;border: 0px"   readonly name="toPrice" class='money' value="￥\${productPrice}" id="\${index}"/></span></td>`);

                    row.append(removeCell);
                    row.append(thumbnailCell);
                    row.append(sizeName);
                    row.append(priceCell);
                    row.append(quantityCell);
                    row.append(totalCell);
                    $("#shop_cart").append(row);


                })
            }

        })
    }

    function count_price(price, quantity, id, product_id) {
        let data = {productQuantity: quantity.value, id: product_id}
        $.ajax({
            url: "shopCart/updateShopCart",
            dataType: "json",
            contentType: "application/json; charset=UTF-8",
            type: "PUT",
            data: JSON.stringify(data),
            success: function (response) {
                if (response.code !== 200) {
                    alert(response.msg)
                } else {
                    const phone =${sessionScope.consumer.consumerPhone};
                    priceBill(phone)

                }

            },
            error: function () {
                alert("出错了")
            }
        })
        let productPrice = price * quantity.value
        $("#" + id).val("￥" + productPrice)

    }

    function removeFromShopCart(id) {

        $.ajax({
            url: "shopCart/" + id,
            dataType: "json",
            type: "DELETE",
            contentType: "application/json; charset=UTF-8",
            success: function (response) {
                if (response.code !== 200) {
                    alert(response.msg)
                } else {
                    const phone =${sessionScope.consumer.consumerPhone};
                     getCart(phone)
                    priceBill(phone)

                }
            }, error: function () {
                alert("出错了")
            }
        })
    }

    function emptyShopCart(phone) {
        $.ajax({
            url: "shopCart/emptyShopCart/" + phone,
            dataType: "json",
            type: "DELETE",
            contentType: "application/json; charset=UTF-8",
            success: function (response) {
                if (response.code !== 200) {
                    alert(response.msg)
                } else {
                     getCart(phone)
                    priceBill(phone)

                }

            }
        })
    }

    function key_8(id) {

        // 监听回退键的按下
        $(id).keydown(function(event) {
            if (event.keyCode === 8) { // 回退键的键码是8
                var inputValue = $(this).val();
                if (inputValue.length === 1) { // 输入框中只有一个数字时
                    $(this).val('1'); // 将数字转为1
                    event.preventDefault(); // 阻止回退键的默认行为
                }
            }
        });
    }


    function showSize(img,id,name,sizeName){
    $("#product").empty()
$("#product").append(`
<h4 style=""><strong style="padding-left: 40%;position: relative;left: -180px;top: 20px ">商品名称 : \${name}</strong></h4>
<img style="padding-left: 40%;position: relative;left: -18px; " alt='Product Thumnail' src='senshi_official_website/static/picture/\${img}' width="70%" height="88%">
<h2><strong style="position: relative;right: -18px;top: -40px ">当前选择 : \${sizeName}</strong></h2>
<input id="id" style="display: none" value="\${id}"/>
`)

}
function updateSize(){
  let size = $("[name=size]:checked").val();
  let cartId = $("#id").val();
   let data= {sizeId:size,id:cartId};
   data=JSON.stringify(data)

$.ajax({
    url:"shopCart/updateSize",
    dataType:"json",
    data: data,
    type: "PUT",
    contentType:"application/json;charset=UTF-8",
    success: function(response){
        if (response.code!==200){
            alert(response.msg)
        }else {
            const phone =${sessionScope.consumer.consumerPhone};
            getCart(phone)
            priceBill(phone)
        }

    },error:function (){

    }
})
}

    function priceBill(phone) {
        $.ajax({
            url: "shopCart/bill/" + phone,
            dataType: "json",
            type: "get",
            contentType: "application/json; charset=utf-8",
            success: function (response) {
                console.log(response);
                if (response.data !== "尚未选购商品") {
                    $("#subtotal").html("￥" + response.data)
                    $("#TotalPrice").html("￥" + response.data + "和邮寄费")
                } else {
                    $("#TotalPrice").html(response.data)
                    $("#subtotal").html(response.data)
                }
            }
        })
    }

    function goCheckout(){
        var $name = $('[name=toPrice]');
        let bool=false;
        for (let x=0 ; x<$name.length;x++) {
            bool = $name[x].value >= 1;
        }
        if (!bool) {
            window.location.href="goCheckout"
        }else {
            alert("商品数据异常无法前往结账")
        }

    }


</script>
</html>